using System.Collections.Generic;

public class Laya2ScriptHandle : ScriptHandleBase
{
    /// <summary>
    /// 导出正常版代码
    /// </summary>
    public override void ExportScript(List<ExcelData> list, string path)
    {
        ExportClassScript(list, path);
    }

    /// <summary>
    /// 导出压缩版代码
    /// </summary>
    public override void ExportCompressScript(List<ExcelData> list, string path)
    {
        ExportClassScript(list, path);
    }

    /// <summary>
    /// 导出Config类代码
    /// </summary>
    public override void ExportClassScript(List<ExcelData> list, string path)
    {
        for (int i = 0; i < list.Count; i++)
        {
            ExcelData data = list[i];

            string script_str = "export namespace Config {\n";
            script_str += $"\texport class {data.name}" + " {\n";
            for (int j = 0; j < data.types.Count; j++)
            {
                script_str += $"\t\tpublic {data.fields[j]}: {data.types[j]};\n";
            }
            script_str += "\t}\n}";
            FileHandle.SaveFile(script_str, path + data.name + ".ts");
            LogTool.WriteLog($"导出代码: {data.name}.ts");
        }
    }
}
